package com.masterclient.app.modules.chezhubang;

import com.masterclient.app.httpservice.RetrofitUtil;
import com.eoner.baselib.container.CommonBaseResponse;

import java.util.Map;

import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/09
*/
public class CzbAuthorizePresenter extends CzbAuthorizeContract.Presenter{


    @Override
    public void czbAuth() {
        mRxManager.add(toSubscribe(RetrofitUtil.getInstance().czbAuth(), new Consumer<CommonBaseResponse<Map<String,String>>>() {
            @Override
            public void accept(CommonBaseResponse<Map<String,String>> data) throws Exception {
                if (data.getCode() == 0){
                    mView.authSuccess(data.getData());
                }else {
                    mView.authFailed(data.getMsg());
                }
            }
        },new Consumer<Throwable>() {
            @Override
            public void accept(@NonNull Throwable o) throws Exception {
                o.printStackTrace();
                mView.authFailed(o.getMessage());
            }
        }));
    }
}